package com.google.gwt.mobile.phonegap.api;

import java.util.Date;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;

/**
 * The Class FileMgr.
 */
public class FileMgr {

  protected FileMgr() {
  }

  // New instance creation
  /**
   * New reader instance.
   * 
   * @return the file reader
   */
  public static native FileReader newReaderInstance() /*-{
		return new $wnd.FileReader();
  }-*/;

  /**
   * Request file system.
   * 
   * @param localFileSystem the local file system
   * @param callback the callback
   */
  public static void requestFileSystem(final LocalFileSystem localFileSystem,
      final FileSystemCallback callback) {
    requestFileSystemNative(localFileSystem.ordinal(), callback);
  }

  private static native void requestFileSystemNative(int type, FileSystemCallback callback) /*-{
		$wnd
				.requestFileSystem(
						type,
						0,
						function(success) {
							callback.@com.google.gwt.mobile.phonegap.api.FileMgr.FileSystemCallback::onSuccess(Lcom/google/gwt/mobile/phonegap/api/FileMgr$FileSystem;)(success);
						},
						function(error) {
							callback.@com.google.gwt.mobile.phonegap.api.FileMgr.FileSystemCallback::onError(Lcom/google/gwt/mobile/phonegap/api/FileMgr$FileError;)(error);
						});
  }-*/;

  /**
   * The Enum LocalFileSystem.
   */
  public enum LocalFileSystem {
    TEMPORARY, PERSISTENT
  };

  // fileMgr methods are not in phonegap doc yet. Only selected APIs are
  // wrapped.

  /**
   * Test file exists.
   * 
   * @param fileName the file name
   * @param callback the callback
   */
  public static native void testFileExists(String fileName, FileMgrCallback callback) /*-{
		$wnd.navigator.fileMgr
				.testFileExists(
						fileName,
						function(success) {
							callback.@com.google.gwt.mobile.phonegap.api.FileMgr.FileMgrCallback::onSuccess(Z)(success);
						},
						function(error) {
							callback.@com.google.gwt.mobile.phonegap.api.FileMgr.FileMgrCallback::onError(Lcom/google/gwt/mobile/phonegap/api/FileMgr$FileError;)(error);
						});
  }-*/;

  /**
   * Test directory exists.
   * 
   * @param dirName the dir name
   * @param callback the callback
   */
  public static native void testDirectoryExists(String dirName, FileMgrCallback callback) /*-{
		$wnd.navigator.fileMgr
				.testDirectoryExists(
						dirName,
						function(success) {
							callback.@com.google.gwt.mobile.phonegap.api.FileMgr.FileMgrCallback::onSuccess(Z)(success);
						},
						function(error) {
							callback.@com.google.gwt.mobile.phonegap.api.FileMgr.FileMgrCallback::onError(Lcom/google/gwt/mobile/phonegap/api/FileMgr$FileError;)(error);
						});
  }-*/;

  /**
   * Gets the free disk space.
   * 
   * @param callback the callback
   * @return the free disk space
   */
  public static native void getFreeDiskSpace(FreeDiskSpaceCallback callback) /*-{
		$wnd.navigator.fileMgr
				.getFreeDiskSpace(
						function(freeDiskSpace) {
							callback.@com.google.gwt.mobile.phonegap.api.FileMgr.FreeDiskSpaceCallback::onSuccess(D)(freeDiskSpace);
						},
						function(error) {
							callback.@com.google.gwt.mobile.phonegap.api.FileMgr.FreeDiskSpaceCallback::onError(Lcom/google/gwt/mobile/phonegap/api/FileMgr$FileError;)(error);
						});
  }-*/;

  // File System
  /**
   * The Class FileSystem.
   */
  public static class FileSystem extends JavaScriptObject {

    protected FileSystem() {
    };

    /**
     * Gets the name.
     * 
     * @return the name
     */
    public final native String getName() /*-{
			return this.name;
    }-*/;

    /**
     * Gets the root.
     * 
     * @return the root
     */
    public final native DirectoryEntry getRoot() /*-{
			return this.root;
    }-*/;
  }

  // Directory Entry
  /**
   * The Class DirectoryEntry.
   */
  public static class DirectoryEntry extends Entry {

    protected DirectoryEntry() {
    };

    /**
     * Creates the reader.
     * 
     * @return the directory reader
     */
    public final native DirectoryReader createReader() /*-{
			return this.createReader();
    }-*/;

    /**
     * Gets the directory.
     * 
     * @param path the path
     * @param options the options
     * @param callback the callback
     * @return the directory
     */
    public final void getDirectory(final String path, final FileOptions options,
        final EntryCallback callback) {
      getDirectoryNative(path, options == null ? null : options.getOptions(), callback);
    }

    private final native void getDirectoryNative(String path, JavaScriptObject options,
        EntryCallback callback) /*-{
			this
					.getDirectory(
							path,
							options,
							function(success) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EntryCallback::onSuccess(Lcom/google/gwt/mobile/phonegap/api/FileMgr$Entry;)(success);
							},
							function(error) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EntryCallback::onError(Lcom/google/gwt/mobile/phonegap/api/FileMgr$FileError;)(error);
							});
    }-*/;

    /**
     * Gets the file.
     * 
     * @param path the path
     * @param options the options
     * @param callback the callback
     * @return the file
     */
    public final void getFile(final String path, final FileOptions options,
        final EntryCallback callback) {
      getFileNative(path, options.getOptions(), callback);
    }

    private final native void getFileNative(String path, JavaScriptObject options,
        EntryCallback callback) /*-{
			this
					.getFile(
							path,
							options,
							function(success) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EntryCallback::onSuccess(Lcom/google/gwt/mobile/phonegap/api/FileMgr$Entry;)(success);
							},
							function(error) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EntryCallback::onError(Lcom/google/gwt/mobile/phonegap/api/FileMgr$FileError;)(error);
							});
    }-*/;

    /**
     * Removes the recursively.
     * 
     * @param callback the callback
     */
    public final native void removeRecursively(FileMgrCallback callback) /*-{
			this
					.removeRecursively(
							function(success) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.FileMgrCallback::onSuccess(Z)(true);
							},
							function(error) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.FileMgrCallback::onError(Lcom/google/gwt/mobile/phonegap/api/FileMgr$FileError;)(error);
							});
    }-*/;

  }

  // Flags
  /**
   * The Class FileOptions.
   */
  public static class FileOptions {
    FileOptions self = this;
    JavaScriptObject options = JavaScriptObject.createObject();

    /**
     * Creates the.
     * 
     * @param create the create
     * @return the file options
     */
    public native FileOptions create(boolean create) /*-{
			this.@com.google.gwt.mobile.phonegap.api.FileMgr.FileOptions::options.create = create;
			return this.@com.google.gwt.mobile.phonegap.api.FileMgr.FileOptions::self;
    }-*/;

    /**
     * Exclusive.
     * 
     * @param exclusive the exclusive
     * @return the file options
     */
    public native FileOptions exclusive(boolean exclusive) /*-{
			this.@com.google.gwt.mobile.phonegap.api.FileMgr.FileOptions::options.exclusive = exclusive;
			return this.@com.google.gwt.mobile.phonegap.api.FileMgr.FileOptions::self;
    }-*/;

    private JavaScriptObject getOptions() {
      return options;
    }
  }

  // Directory Reader
  /**
   * The Class DirectoryReader.
   */
  public static class DirectoryReader extends Entry {

    protected DirectoryReader() {
    };

    /**
     * Read entries.
     * 
     * @param callback the callback
     */
    public final native void readEntries(ReaderCallback callback) /*-{
			this
					.readEntries(
							function(success) {
								$entry(@com.google.gwt.mobile.phonegap.api.FileMgr.DirectoryReader::processCallback(Lcom/google/gwt/core/client/JsArray;Lcom/google/gwt/mobile/phonegap/api/FileMgr$ReaderCallback;)(success, callback));
							},
							function(error) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.ReaderCallback::onError(Lcom/google/gwt/mobile/phonegap/api/FileMgr$FileError;)(error);
							});
    }-*/;

    /**
     * Process callback.
     * 
     * @param results the results
     * @param callback the callback
     */
    public final static void processCallback(final JsArray<JavaScriptObject> results,
        final ReaderCallback callback) {
      Entry[] entries = new Entry[results.length()];
      for (int i = 0; i < results.length(); i++) {
        entries[i] = (Entry) results.get(i);
      }
      callback.onSuccess(entries);
    }
  }

  // File Entry
  /**
   * The Class FileEntry.
   */
  public static class FileEntry extends Entry {

    protected FileEntry() {
    };

    /**
     * Creates the writer.
     * 
     * @param callback the callback
     * @return the file writer
     */
    public final native FileWriter createWriter(FileWriterCallback callback) /*-{
			this
					.createWriter(
							function(success) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.FileWriterCallback::onSuccess(Lcom/google/gwt/mobile/phonegap/api/FileMgr$FileWriter;)(success);
							},
							function(error) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.FileWriterCallback::onError(Lcom/google/gwt/mobile/phonegap/api/FileMgr$FileError;)(error);
							});
    }-*/;

    /**
     * File.
     * 
     * @param callback the callback
     * @return the file
     */
    public final native File file(FileCallback callback) /*-{
			this
					.file(
							function(success) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.FileCallback::onSuccess(Lcom/google/gwt/mobile/phonegap/api/FileMgr$File;)(success);
							},
							function(error) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.FileCallback::onError(Lcom/google/gwt/mobile/phonegap/api/FileMgr$FileError;)(error);
							});
    }-*/;

  }

  // File
  /**
   * The Class File.
   */
  public final static class File extends JavaScriptObject {

    protected File() {
    };

    /**
     * Gets the name.
     * 
     * @return the name
     */
    public final native String getName() /*-{
			return this.name;
    }-*/;

    /**
     * Gets the full path.
     * 
     * @return the full path
     */
    public final native String getFullPath() /*-{
			return this.fullPath;
    }-*/;

    /**
     * Gets the last modified date.
     * 
     * @return the last modified date
     */
    @SuppressWarnings("deprecation")
    public final Date getLastModifiedDate() {
      return new Date(Date.parse(getLastModifiedDateNative()));
    };

    private final native String getLastModifiedDateNative() /*-{
			return this.lastModifiedDate;
    }-*/;

    /**
     * Gets the size.
     * 
     * @return the size
     */
    public final long getSize() {
      return (long) getSizeNative();
    };

    private final native double getSizeNative() /*-{
			return this.size;
    }-*/;

  }

  // Entry Base
  /**
   * The Class Entry.
   */
  public static class Entry extends JavaScriptObject {

    protected Entry() {
    };

    /**
     * Checks if is file.
     * 
     * @return the boolean
     */
    public final native Boolean isFile() /*-{
			return this.isFile;
    }-*/;

    /**
     * Checks if is directory.
     * 
     * @return the boolean
     */
    public final native Boolean isDirectory() /*-{
			return this.isDirectory;
    }-*/;

    /**
     * Gets the name.
     * 
     * @return the name
     */
    public final native String getName() /*-{
			return this.name;
    }-*/;

    /**
     * Gets the full path.
     * 
     * @return the full path
     */
    public final native String getFullPath() /*-{
			return this.fullPath;
    }-*/;

    /**
     * Gets the metadata.
     * 
     * @param callback the callback
     * @return the metadata
     */
    public final native String getMetadata(MetadataCallback callback) /*-{
			this
					.getMetadata(
							function(success) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.MetadataCallback::onSuccess(Lcom/google/gwt/mobile/phonegap/api/FileMgr$Metadata;)(success);
							},
							function(error) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.MetadataCallback::onError(Lcom/google/gwt/mobile/phonegap/api/FileMgr$FileError;)(error);
							});
    }-*/;

    /**
     * Move to.
     * 
     * @param entry the entry
     * @param newName the new name
     * @param callback the callback
     */
    public final native void moveTo(Entry entry, String newName, EntryCallback callback) /*-{
			this
					.moveTo(
							entry,
							newName,
							function(success) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EntryCallback::onSuccess(Lcom/google/gwt/mobile/phonegap/api/FileMgr$Entry;)(success);
							},
							function(error) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EntryCallback::onError(Lcom/google/gwt/mobile/phonegap/api/FileMgr$FileError;)(error);
							});
    }-*/;

    /**
     * Copy to.
     * 
     * @param entry the entry
     * @param newName the new name
     * @param callback the callback
     */
    public final native void copyTo(Entry entry, String newName, EntryCallback callback) /*-{
			this
					.copyTo(
							entry,
							newName,
							function(success) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EntryCallback::onSuccess(Lcom/google/gwt/mobile/phonegap/api/FileMgr$Entry;)(success);
							},
							function(error) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EntryCallback::onError(Lcom/google/gwt/mobile/phonegap/api/FileMgr$FileError;)(error);
							});
    }-*/;

    /**
     * To uri.
     * 
     * @return the string
     */
    public final native String toURI() /*-{
			return this.toURI();
    }-*/;

    /**
     * Removes the.
     * 
     * @param callback the callback
     */
    public final native void remove(FileMgrCallback callback) /*-{
			this
					.remove(
							function() {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.FileMgrCallback::onSuccess(Z)(true);
							},
							function(error) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.FileMgrCallback::onError(Lcom/google/gwt/mobile/phonegap/api/FileMgr$FileError;)(error);
							});
    }-*/;

    /**
     * Gets the parent.
     * 
     * @param callback the callback
     * @return the parent
     */
    public final native void getParent(EntryCallback callback) /*-{
			this
					.getParent(
							function(success) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EntryCallback::onSuccess(Lcom/google/gwt/mobile/phonegap/api/FileMgr$Entry;)(success);
							},
							function(error) {
								callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EntryCallback::onError(Lcom/google/gwt/mobile/phonegap/api/FileMgr$FileError;)(error);
							});
    }-*/;

  }

  // Metadata
  /**
   * The Class Metadata.
   */
  public static class Metadata extends JavaScriptObject {

    protected Metadata() {
    };

    /**
     * Gets the modification time.
     * 
     * @return the modification time
     */
    @SuppressWarnings("deprecation")
    public final Date getModificationTime() {
      return new Date(Date.parse(getModificationTimeNative()));
    };

    private final native String getModificationTimeNative() /*-{
			return this.modificationTime;
    }-*/;

  }

  // FileBase
  /**
   * The Class FileBase.
   */
  public static class FileBase extends JavaScriptObject {

    protected FileBase() {
    };

    protected final native int getReadyStateNative() /*-{
			return this.readyState;
    }-*/;

    // TODO: phonegap doc does not mention this property on the reader. but
    // the
    // code seems to differ.
    /**
     * Gets the file name.
     * 
     * @return the file name
     */
    public final native String getFileName() /*-{
			return this.fileName;
    }-*/;

    // move this method to base so onload event does not have to cast target
    // to
    // a reader.
    // writer does not have this property and this method should not be
    // called
    // on a writer.
    /**
     * Gets the result.
     * 
     * @return the result
     */
    public final native String getResult() /*-{
			return this.result;
    }-*/;

    /**
     * Gets the error.
     * 
     * @return the error
     */
    public final native FileError getError() /*-{
			return this.error;
    }-*/;

    /**
     * On progress.
     * 
     * @param callback the callback
     */
    public final native void onProgress(EventCallback callback) /*-{
			this.onprogress = function(event) {
				callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EventCallback::onEvent(Lcom/google/gwt/mobile/phonegap/api/FileMgr$Event;)(event);
			};
    }-*/;

    /**
     * On abort.
     * 
     * @param callback the callback
     */
    public final native void onAbort(EventCallback callback) /*-{
			this.onabort = function(event) {
				callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EventCallback::onEvent(Lcom/google/gwt/mobile/phonegap/api/FileMgr$Event;)(event);
			};
    }-*/;

    /**
     * On error.
     * 
     * @param callback the callback
     */
    public final native void onError(EventCallback callback) /*-{
			this.onerror = function(event) {
				callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EventCallback::onEvent(Lcom/google/gwt/mobile/phonegap/api/FileMgr$Event;)(event);
			};
    }-*/;

    /**
     * Abort.
     */
    public final native void abort() /*-{
			this.abort();
    }-*/;
  }

  /**
   * The Class FileReader.
   */
  public static class FileReader extends FileBase {

    protected FileReader() {
    };

    /**
     * The Enum ReadyState.
     */
    public enum ReadyState {
      EMPTY, LOADING, DONE
    };

    /**
     * Gets the ready state.
     * 
     * @return the ready state
     */
    public final ReadyState getReadyState() {
      return ReadyState.values()[getReadyStateNative()];
    }

    /**
     * On load start.
     * 
     * @param callback the callback
     */
    public final native void onLoadStart(EventCallback callback) /*-{
			this.onloadstart = function(event) {
				callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EventCallback::onEvent(Lcom/google/gwt/mobile/phonegap/api/FileMgr$Event;)(event);
			};
    }-*/;

    /**
     * On load.
     * 
     * @param callback the callback
     */
    public final native void onLoad(EventCallback callback) /*-{
			this.onload = function(event) {
				callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EventCallback::onEvent(Lcom/google/gwt/mobile/phonegap/api/FileMgr$Event;)(event);
			};
    }-*/;

    /**
     * On load end.
     * 
     * @param callback the callback
     */
    public final native void onLoadEnd(EventCallback callback) /*-{
			this.onloadend = function(event) {
				callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EventCallback::onEvent(Lcom/google/gwt/mobile/phonegap/api/FileMgr$Event;)(event);
			};
    }-*/;

    /**
     * Read as data url.
     * 
     * @param file the file
     */
    public final native void readAsDataURL(File file) /*-{
			this.readAsDataURL(file);
    }-*/;

    /**
     * Read as text.
     * 
     * @param file the file
     */
    public final native void readAsText(File file) /*-{
			this.readAsText(file);
    }-*/;

  }

  /**
   * The Class FileWriter.
   */
  public static class FileWriter extends FileBase {

    protected FileWriter() {
    };

    /**
     * The Enum ReadyState.
     */
    public enum ReadyState {
      INIT, WRITING, DONE
    };

    /**
     * Gets the ready state.
     * 
     * @return the ready state
     */
    public final ReadyState getReadyState() {
      return ReadyState.values()[getReadyStateNative()];
    }

    /**
     * Gets the length.
     * 
     * @return the length
     */
    public final long getLength() {
      return (long) getLengthNative();
    };

    private final native double getLengthNative() /*-{
			return this.length;
    }-*/;

    /**
     * Gets the position.
     * 
     * @return the position
     */
    public final long getPosition() {
      return (long) getPositionNative();
    };

    private final native double getPositionNative() /*-{
			return this.position;
    }-*/;

    /**
     * On write start.
     * 
     * @param callback the callback
     */
    public final native void onWriteStart(EventCallback callback) /*-{
			this.onwritestart = function(event) {
				callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EventCallback::onEvent(Lcom/google/gwt/mobile/phonegap/api/FileMgr$Event;)(event);
			};
    }-*/;

    /**
     * On write.
     * 
     * @param callback the callback
     */
    public final native void onWrite(EventCallback callback) /*-{
			this.onwrite = function(event) {
				callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EventCallback::onEvent(Lcom/google/gwt/mobile/phonegap/api/FileMgr$Event;)(event);
			};
    }-*/;

    /**
     * On write end.
     * 
     * @param callback the callback
     */
    public final native void onWriteEnd(EventCallback callback) /*-{
			this.onwriteend = function(event) {
				callback.@com.google.gwt.mobile.phonegap.api.FileMgr.EventCallback::onEvent(Lcom/google/gwt/mobile/phonegap/api/FileMgr$Event;)(event);
			};
    }-*/;

    /**
     * Seek.
     * 
     * @param offset the offset
     */
    public final void seek(final long offset) {
      seek((double) offset);
    }

    private final native void seek(double offset) /*-{
			this.seek(offset);
    }-*/;

    /**
     * Truncate.
     * 
     * @param size the size
     */
    public final void truncate(final long size) {
      truncate((double) size);
    }

    private final native void truncate(double size) /*-{
			this.truncate(size);
    }-*/;

    /**
     * Write.
     * 
     * @param text the text
     */
    public final native void write(String text) /*-{
			this.write(text);
    }-*/;

  }

  /**
   * The Enum FileErrorCode.
   */
  public enum FileErrorCode {
    NO_ERROR, // addition to phonegap codes to fill the 0 position.
    NOT_FOUND_ERR, SECURITY_ERR, ABORT_ERR, NOT_READABLE_ERR, ENCODING_ERR, NO_MODIFICATION_ALLOWED_ERR, INVALID_STATE_ERR, SYNTAX_ERR, INVALID_MODIFICATION_ERR, QUOTA_EXCEEDED_ERR, TYPE_MISMATCH_ERR, PATH_EXISTS_ERR
  };

  /**
   * The Class FileError.
   */
  public static class FileError extends JavaScriptObject {

    protected FileError() {
    };

    /**
     * Gets the code.
     * 
     * @return the code
     */
    public final FileErrorCode getCode() {
      return FileErrorCode.values()[getCodeNative()];
    }

    private final native int getCodeNative() /*-{
			// Hey phonegap, where is the consistency?
			return this.code || this;
    }-*/;
  }

  /**
   * The Interface EventCallback.
   */
  public interface EventCallback {
    void onEvent(Event evt);
  }

  /**
   * The Interface FileMgrCallback.
   */
  public interface FileMgrCallback {
    void onSuccess(boolean success);

    void onError(FileError error);
  }

  /**
   * The Interface FreeDiskSpaceCallback.
   */
  public interface FreeDiskSpaceCallback {
    void onSuccess(double freeDiskSpace);

    void onError(FileError error);
  }

  /**
   * The Interface MetadataCallback.
   */
  public interface MetadataCallback {
    void onSuccess(Metadata metadata);

    void onError(FileError error);
  }

  /**
   * The Interface EntryCallback.
   */
  public interface EntryCallback {
    void onSuccess(Entry entry);

    void onError(FileError error);
  }

  /**
   * The Interface ReaderCallback.
   */
  public interface ReaderCallback {
    void onSuccess(Entry[] entries);

    void onError(FileError error);
  }

  /**
   * The Interface FileWriterCallback.
   */
  public interface FileWriterCallback {
    void onSuccess(FileWriter writer);

    void onError(FileError error);
  }

  /**
   * The Interface FileCallback.
   */
  public interface FileCallback {
    void onSuccess(File file);

    void onError(FileError error);
  }

  /**
   * The Interface FileSystemCallback.
   */
  public interface FileSystemCallback {
    void onSuccess(FileSystem result);

    void onError(FileError error);
  }

  /**
   * The Class Event.
   */
  public static class Event extends JavaScriptObject {

    protected Event() {
    };

    /**
     * Gets the type.
     * 
     * @return the type
     */
    public final native String getType() /*-{
			return this.type;
    }-*/;

    /**
     * Gets the target.
     * 
     * @return the target
     */
    public final native FileBase getTarget() /*-{
			return this.target;
    }-*/;

  }

}
